import request from '@/utils/request'

/**
 * 创建菜单
 * @param data
 * @returns {AxiosPromise}
 */
export function create(data) {
  return request({
    url: '/menu',
    method: 'post',
    data: data
  })
}

/**
 * 构建菜单树
 * @returns {AxiosPromise}
 */
export function tree() {
  return request({
    url: '/menu/tree',
    method: 'get'
  })
}

/**
 * id查询菜单
 * @param id
 * @returns {AxiosPromise}
 */
export function findById(id) {
  return request({
    url: '/menu/' + id,
    method: 'get'
  })
}

/**
 * pid查询
 * @param id
 * @returns {AxiosPromise}
 */
export function findByPid(id) {
  return request({
    url: '/menu/par/' + id,
    method: 'get'
  })
}

/**
 * ids删除菜单
 * @param ids
 * @returns {AxiosPromise}
 */
export function deleteByIds(ids) {
  return request({
    url: '/menu',
    method: 'delete',
    data: ids
  })
}

/**
 * 条件查询菜单
 * @param data
 * @returns {AxiosPromise}
 */
export function findAll(data) {
  return request({
    url: '/menu/search',
    method: 'post',
    data: data
  })
}

/**
 * id更新菜单
 * @param data
 * @returns {AxiosPromise}
 */
export function updateById(data) {
  return request({
    url: '/menu',
    method: 'put',
    data: data
  })
}
